<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // 封装一个排序
        function sort(arr) {
            for (var i = 1; i < arr.length; i++) {
                var j = i - 1;
                var temp = arr[i];
                while (j >= 0 && temp < arr[j]) {
                    arr[j + 1] = arr[j];
                    j--;
                }
                arr[j + 1] = temp;
            }
        }
        var arr1 = [1, 3, 2, 6, 5];
        sort(arr1); // 修改了原数组
        console.log(arr1);
    </script>
</body>

</html>